home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / CURDIR.C < prev    next >
C/C++ Source or Header  |  1990-10-22  |  1KB  |  51 lines

  1. /*********
  2. *  CURDIR.C
  3. *
  4. *  by Leonard Zerman 
  5. *
  6. * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. *
  8. *  Syntax: CURDIR( [<expC>] )
  9. *  Return: Full drive and path of current directory
  10. *  Note  : Null if invalid drive.
  11. *********/
  12.  
  13. #include <trlib.h>
  14.  
  15. static char path[67]; 
  16. char *get_dir2();
  17.  
  18. TRTYPE curdir()
  19. {
  20.    char *drive;
  21.    char *dir;
  22.  
  23.    if(PCOUNT <= 1)
  24.    {
  25.        if(PCOUNT == 0)
  26.           path[0] = (char)(get_drive() + 'A');
  27.        else if (PCOUNT == 1 && ISCHAR(1))
  28.        {
  29.           drive   = _parc(1);
  30.           path[0] = toupper(drive[0]);
  31.        }
  32.        else
  33.        {
  34.           _retc(NULLS);         /* Wrong parameters */
  35.           return;
  36.        }   
  37.        path[1] = ':';
  38.        dir = get_dir2(path[0] - 'A');
  39.        if(dir)
  40.        {
  41.           _tr_strcpy(path+2,dir);
  42.           _retc(path);
  43.           return;
  44.        }
  45.        else
  46.           _retc(NULLS);         /* No drive */
  47.    }
  48.    else
  49.       _retc(NULLS);         /* Wrong parameters */
  50. }
  51.